package com.linlang.grasharepro.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.linlang.grasharepro.R;
import com.linlang.grasharepro.dao.ExperienceDB;
import com.linlang.grasharepro.dao.ShareCoentenDB;
import com.linlang.grasharepro.model.Experience;
import com.linlang.grasharepro.model.ShareCoenten;

/**
 * Created by lixin on 2016-8-14.
 */
public class MingPian extends Activity {
    private LinearLayout layout;
    private ShareCoenten info = null;
    private TextView mingpina_year, mingpian_company, mingpian_where, mingpian_workcontent, mingpian_money, mingpian_exrper, mingpian_difftent, tv_contacts, tv_contactsway;
    private ExperienceDB experienceDB;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mingpian_dialog);
        // 获取从列表当中传递过来的数据
        Intent intent = getIntent();
        Bundle bund = intent.getExtras();
        info = (ShareCoenten) bund.getSerializable("shareContent");
        initView();
        initData();

        layout = (LinearLayout) findViewById(R.id.exit_layout);
        layout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Toast.makeText(getApplicationContext(), "提示：点击窗口外部关闭窗口！",
                        Toast.LENGTH_SHORT).show();
            }
        });
    }

    public void initData() {
        experienceDB = new ExperienceDB(this);
        experienceDB.open();
        Experience experience = experienceDB.queryById(info.getExperienceId());

        mingpina_year.setText(experience.getGraduationTime());
        mingpian_company.setText(experience.getCompany());
        mingpian_where.setText(experience.getPosition());
        mingpian_workcontent.setText(experience.getContent());
        mingpian_money.setText(experience.getTreatment());
        mingpian_exrper.setText(experience.getExperince());
        mingpian_difftent.setText(experience.getDifferent());
        tv_contacts.setText(experience.getRelation());
        tv_contactsway.setText(experience.getRelationWay());
    }

    public void initView() {
        mingpina_year = (TextView) findViewById(R.id.mingpina_year);
        mingpian_company = (TextView) findViewById(R.id.mingpian_company);
        mingpian_where = (TextView) findViewById(R.id.mingpian_where);
        mingpian_workcontent = (TextView) findViewById(R.id.mingpian_workcontent);
        mingpian_money = (TextView) findViewById(R.id.mingpian_money);
        mingpian_exrper = (TextView) findViewById(R.id.mingpian_exrper);
        mingpian_difftent = (TextView) findViewById(R.id.mingpian_difftent);
        tv_contacts = (TextView) findViewById(R.id.tv_contacts);
        tv_contactsway = (TextView) findViewById(R.id.tv_contactsway);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        finish();
        return true;
    }
}
